<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>手机注册</title>
    <base href="<?php echo base_url();?>"/>
    <link href="style/base.css" rel="stylesheet" type="text/css" />
    <link href="style/common.css" rel="stylesheet" type="text/css" />
    <link href="style/zhuce.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.enplaceholder.js"></script>
    <script src="js/organictabs.jquery.js"></script>
    <script type="text/javascript" src="js/Common.js"></script>
    <script type="text/javascript" src="js/Validation.js"></script>
    <script type="text/javascript" language="javascript">
        // 文本框placeholder效果,给input加上类ph,使其支持placeholder效果
        $(function(){
            $('input.ph').placeholder({isUseSpan:true});
        })
    $(function () {
        $("#txtPhone").bind("blur",checkPhone);
        $("#txtPwd").bind("blur",checkPwd);
        $("#txtPwds").bind("blur",checkPwds);
        $("#txtCheckCode").bind("blur",checkCode);
        $("#btnGetCode").bind("click",getSmsCode);
        $("#btnCheckCode").bind("click",checkCode);
        $("#btnSubmit").bind("click",submit);

        //initSelected();
    });
    function submit(){

        if($("#agreement").attr("checked") !='checked'){
            alert("您需要同意协议才能够注册")
            return false;
        }
        if(checkPhone()==false)
            return;
        if(checkPwd()==false)
            return;
        if(checkPwds()==false)
            return;
        if(checkCode()==false)
            return;



        $('#formReg').submit();
    }
    function getSmsCode(){
        $("#btnGetCode").unbind("click");
        if(checkPhone()==false){
            $("#btnGetCode").bind("click",getSmsCode);
            return;
        }
        var params = {
            phone:$("#txtPhone").val()
        };
        $.ajax({
            type:"post",
            url:"index.php/login/sendSms",
            dataType:"html",
            data:params,
            async:false,
            success:function(data){
                //$("#divTest").html(data);
            }
        });
        $("#btnGetCode").bind("click",getSmsCode);
        //fun_timedown(300);
        return false;
    }
    function checkPhone(){
        var phone = $("#txtPhone").val();
        if(IsEmpty(phone)){
            SetError("txtPhone","请输入手机号");
            return false;
        }
        if(!IsMobile(phone)){
            SetError("txtPhone","非有效手机号");
            return false;
        }
        var isok=true;
        var params = {phone:phone};
        $.ajax({
            type:"post",
            url:"index.php/login/checkPhoneForRegister",
            dataType:"json",
            data:params,
            async:false,
            success:function(data){
                if(data.ReturnCode!=1){
                    SetError("txtPhone",data.Msg);
                    isok=false;
                }
            }
        });
        if(isok==false)
            return false;
        SetOK("txtPhone");
        return true;
    }
    function checkPwd(){
        var pwd = $("#txtPwd").val();
        if(IsEmpty(pwd)){
            SetError("txtPwd","请输入密码");
            return false;
        }
        var len = pwd.length;
        if(len<5 || len>20){
            SetError("txtPwd","密码长度为5 到 12位");
            return false;
        }
        SetOK("txtPwd");
        return true;
    }
    function checkPwds()
    {
        var pwd = $("#txtPwd").val();
        var pwds = $("#txtPwds").val();
        if(IsEmpty(pwds)){
            SetError("txtPwds","请输入密码");
            return false;
        }

        if(pwd !=pwds){
            SetError("txtPwds","两次密码不一致");
            return false;
        }
        SetOK("txtPwds");
        return true;
    }

    function checkCode(){
        ClearError("txtCheckCode");
        var code = $("#txtCheckCode").val();
        var phone = $("#txtPhone").val();
        if(IsEmpty(code)){
            SetError("txtCheckCode","请输入手机验证码");
            return false;
        }
        if(checkPhone()==false)
            return false;
        var params = {
            phone:phone,
            code:code
        };
        var isok=true;
        $.ajax({
            type:"post",
            url:"index.php/login/checkSmsCode",
            dataType:"json",
            data:params,
            async:false,
            success:function(data){
                if(data.ReturnCode!=1){
                    SetError("txtCheckCode","验证码不符");
                    isok=false;
                }
            }
        });
        if(isok==false)
            return false;
        //验证通过
        SetOK("txtCheckCode");
        return true;
    }
   /*function fun_timedown(time){
        $("#btnGetCode").hide();
        if(time=='undefined')
            time = 300;
        $("#spanSeconds").html("验证码已成功发送，"+time+"秒");

        time = time-1;
        if(time>=0)
        {
            setTimeout("fun_timedown("+time+")",1000);
        }else
        {
            //alert('倒计时结束啦');
            $("#btnGetCode").show();
            $("#spanSeconds").html('');
        }
    }*/
    </script>
</head>

<body>
<!-- head S-->
<?php include 'login_header.php';?>
<!-- head E-->
<!-- top S-->
<div class="top_zc">
    <div class="logo"><img src="images/logo_big.png" /></div>
    <div class="tit"><img src="images/txt_dzgn.png" /></div>
    <ul>
        <li class="icon_weixin">官方微信：hellomadou</li>
        <li class="icon_weibo">官方微博：hellomadou</li>
    </ul>
</div>
<!-- top E-->

<!-- 注册 S-->
<div class="register_zc">
    <div class="register_zc_inner">
        <ul class="register_tit" id="register_tit">
            <li><a class="btn_email" href="index.php/login/registere">邮箱注册</a></li>
            <li class="current"><a href="javascript:void(0)" class="btn_phone">手机注册</a></li>
        </ul>
        <div class="register_cnt" id="register_cnt">
            <!--手机注册-->
            <div>
                <form action="index.php/login/registerpsubmit" method="post" id="formReg">
                    <input type="text" class="form_text ph" placeholder="手机号码" value="" id="txtPhone" name="phone"/>
                    <input type="password" class="form_text ph" placeholder="输入密码" value="" id="txtPwd" name="pwd"/>
                    <input type="password" class="form_text ph" placeholder="再次输入密码" value="" id="txtPwds" name="pwds"/>
                    <div class="form_yz_box">
                        <input type="text" class="form_text ph" placeholder="短信验证码" value="" id="txtCheckCode" name="code" /> <input type="button"id="btnGetCode"  class="form_btn_yz" value="获取验证码" />
                    </div>
                    <div class="form_cb_box">
                        <label><input type="checkbox" class="form-checkbox" id="agreement"/><span>已阅读并同意星探麻豆注册服务协议</span></label>
                    </div>
                    <div class="form_btn_box">
                        <input type="button" class="form_btn" id="btnSubmit" value="立即注册" />
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- 注册 E-->

<!-- 登录 S-->
<div class="login_zc">
    <div class="w1100">
        <div class="form">
            <form action="" method="">
                <input type="text" class="form_text ph" placeholder="手机号/邮箱" value="" />
                <input type="password" class="form_text ph" placeholder="登录密码" value="" />
                <input type="submit" class="form_login" value="登 录" />
                <a href="" class="btn_regedit">注 册</a>
            </form>
        </div>
        <ul>
            <li class="btn_login_weibo"><a href="#" >微博账号登录</a></li>
            <li class="btn_login_qq"><a href="#">QQ账号登录</a></li>
            <li class="txt"><img src="images/txt_zcjks.png" /></li>
        </ul>
    </div>
</div>
<!-- 登录 E-->

<!-- 底部 开始 -->
<?php include 'footer.php';?>
<!-- 底部 结束 -->
</body>
</html>
